package com.woniuxy.classteacher.cofiguration;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author 李英勇
 * @date 2020/7/17 - 15:23
 * 作目录映射，将video的访问路径与存储路径映射
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    //注入文件配置类
    @Autowired
    private FileUploadProperties fileUploadProperties;

    //为tomcat请求路径配置虚拟目录
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        System.out.println(1111);
        registry.addResourceHandler(fileUploadProperties.getStaticAccessPath())
                .addResourceLocations("file:"+fileUploadProperties.getUploadFolder());
    }

}
